GitHub ActionsでPythonのコードを整えたい
https://github.com/ftnext/python-actions-example
stefanzweifel/git-auto-commit-actionが使えるかも(PHPの例)
CIでまず以下を実施してから後続のmypyやテスト実行に回す
black
isort
autoflake8
コードを整えたいので、GitHub Actionsにて整形したコミットを作りたい
blackやisortはpyproject.tomlで設定すると、configurationを繰り返さなくてよくなる
もうPythonの細かい書き方で議論しない。blackで自動フォーマットしよう 参照
https://pycqa.github.io/isort/docs/configuration/config_files.html#pyprojecttoml-preferred-format
blackで整形したコミットをGitHub Actionsで作る
Black document: GitHub Actions integration
GitHub Actionsでblackで整形したコミット 実装例
isortで整形したコミットをGitHub Actionsで作る
GitHub Actionsでisortで整形したコミット 実装例
バグへの対処として、jobをlint-checkとlintに分割
未解決:最初のジョブの終了コードがワークフローの終了ステータスとなるため、lint-checkに失敗するとワークフローは失敗扱い
GitHub uses the exit code of the last executed command to set the action's check run status.
https://github.com/actions/toolkit/issues/908#issuecomment-919609272
👉 GitHub Actionsの1つのJobでPythonのコードを整える
Actionsを使わずに独力で書く参考
https://github.com/actions/toolkit/issues/908 (blackでcheckし、フォーマットする例)
2つのjobで書いていたが、1つのjobにまとめている(black --check .をconditionのように扱うとのこと)
https://github.com/osoken/sqlitecollections/blob/main/.github/workflows/ci.yml